package database

type IteratorFun func(key string, val interface{}) bool

type DictItf interface {
	// Get 获取值
	Get(key string) (val interface{}, exists bool)
	// Len 字典的长度
	Len() int
	// Put 存值
	Put(key string, val interface{}) (result int)
	// PutIfAbsent key不存在设置值
	PutIfAbsent(key string, val interface{}) (result int)
	// PutIfExists key存在时设置,不存在时不设置值
	PutIfExists(key string, val interface{}) (result int)
	// Remove 删除key
	Remove(key string) (result int)
	// ForEach 遍历整个字典,传入的是遍历方法
	ForEach(iteratorFun IteratorFun)
	// Keys 返回所有的key
	Keys() []string
	// RandomKeys 随机返回limit个key
	RandomKeys(limit int) []string
	// RandomDistinctKeys 随机返回不重复的key
	RandomDistinctKeys(limit int) []string
	// Clear 清空字典
	Clear()
}
